#include"console.h"
#include"sync.h"
#include"print.h"

lock console_lock;

static inline void console_acquire(void);
static inline void console_release(void);


static void console_acquire(void){
	lock_acquire(&console_lock);
}

static void console_release(void){
	lock_release(&console_lock);
}

void init_console(void){
	init_lock(&console_lock);	
}

void console_put_str(const char* str){
	console_acquire();
	put_str(str);
	console_release();
}

void console_put_char(char asci){
	console_acquire();
	put_char(asci);
	console_release();

}

void console_put_int(int32_t num){
	console_acquire();
	put_int(num);
	console_release();
}

void sys_putchar(char c){
	console_put_char(c);
}

void sys_clear(void){
	console_acquire();
	clear_screen();
	console_release();
}
